#include <bits/stdc++.h>

using namespace std;

int n, m;

bool check(int x, unordered_map<int, int>& map)
{
    int tmp = 0;
    for (auto [num, cnt] : map)
    {
        tmp += cnt / x + (cnt % x != 0);
    }
    return tmp <= m;
}

int main()
{
    unordered_map<int, int> map;
    cin >> n >> m;
    int Max = 0;
    for (int i = 0; i < n; i++)
    {
        int tmp;
        cin >> tmp;
        map[tmp]++;
        Max = max(Max, map[tmp]);
    }
    int kinds = map.size();
    if (kinds > m)
    {
        cout << -1 << endl;
        return 0;
    }
    for (int i = 1; i <= Max; i++)
    {
        if (check(i, map))
        {
            cout << i << endl;
            break;
        }
    }



    return 0;
}